package com.zygh.interactiveplatform.module.controller;


import com.alibaba.fastjson.JSONObject;
import com.zygh.interactiveplatform.common.anno.PcLog;
import com.zygh.interactiveplatform.common.constant.SwaggerTagConst;
import com.zygh.interactiveplatform.common.domain.ResponseDTO;
import com.zygh.interactiveplatform.module.entity.Unlawfulact;
import com.zygh.interactiveplatform.module.service.UnlawfulactService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author lee
 * @since 2021-01-29
 */
@RestController
@RequestMapping("/unlawfulact")
@Api(tags = {SwaggerTagConst.Admin.MANAGER_UNLAWFULACT})
public class UnlawfulactController {
    @Resource
    private UnlawfulactService unlawfulactService;

    @ApiOperation(value = "违法行为新增", notes = "违法行为新增")
    @PostMapping("addUnlawfulacte")
    @PcLog(logType = "2", module = SwaggerTagConst.Admin.MANAGER_UNLAWFULACT, content = "违法行为新增")
    public ResponseDTO addUnlawfulacte(@RequestBody @Valid Unlawfulact unlawfulact) {
        return unlawfulactService.addUnlawfulact(unlawfulact);
    }

    @ApiOperation(value = "违法行为修改", notes = "违法行为修改")
    @PostMapping("updateUnlawfulact")
    @PcLog(logType = "3", module = SwaggerTagConst.Admin.MANAGER_UNLAWFULACT, content = "违法行为修改")
    public ResponseDTO updateUnlawfulact(@RequestBody @Valid Unlawfulact unlawfulact) {
        return unlawfulactService.updateUnlawfulact(unlawfulact);
    }

    @ApiOperation(value = "违法行为删除", notes = "违法行为删除")
    @PostMapping("deleteUnlawfulact")
    @PcLog(logType = "4", module = SwaggerTagConst.Admin.MANAGER_UNLAWFULACT, content = "违法行为删除")
    public ResponseDTO deleteUnlawfulact(@RequestBody String id) {
        String s = JSONObject.parseObject(id).get("id").toString();
        Integer new_id = Integer.parseInt(s);
        return unlawfulactService.deleteUnlawfulact(new_id);
    }

    @ApiOperation(value = "查询所有违法行为", notes = "查询所有违法行为")
    @GetMapping("findUnlawfulactAll")
    @PcLog(logType = "1", module = SwaggerTagConst.Admin.MANAGER_UNLAWFULACT, content = "查询所有违法行为")
    public ResponseDTO findUnlawfulactAll(Integer current, Integer size) {
        return unlawfulactService.findUnlawfulactAll(current, size);
    }
}
